package com.allwees.bs.module.oms.wf;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.allwees.core.wf.FsmState;
import com.allwees.core.wf.Transition;

import java.util.Arrays;
import java.util.List;

public enum EOmsOrderItemState implements FsmState<EOmsOrderItemState, EOmsOrderItemAction>, IEnum<String> {

    START("Start", false, false) {
        @Override
        public List<Transition<EOmsOrderItemState, EOmsOrderItemAction>> getTransitions() {
            return Arrays.asList(
                    new Transition<>(EOmsOrderItemAction.SYSTEM_CREATED, WAIT_MERCHANT_SHIP)
            );
        }
    },

    WAIT_MERCHANT_SHIP("Wait_Ship", true, false) {
        @Override
        public List<Transition<EOmsOrderItemState, EOmsOrderItemAction>> getTransitions() {
            return Arrays.asList(
                    new Transition<>(EOmsOrderItemAction.MERCHANT_SHIPPED, MERCHANT_SHIPPED)
            );
        }
    },

    MERCHANT_SHIPPED("Shipped", true, false) {
        @Override
        public List<Transition<EOmsOrderItemState, EOmsOrderItemAction>> getTransitions() {
            return Arrays.asList(
                    new Transition<>(EOmsOrderItemAction.USER_RECEIVED, RECEIVED)
            );
        }
    },

    RECEIVED("Received", true, false) {
        @Override
        public List<Transition<EOmsOrderItemState, EOmsOrderItemAction>> getTransitions() {
            return Arrays.asList(
                    new Transition<>(EOmsOrderItemAction.USER_REVIEWED, COMPLETED),
                    new Transition<>(EOmsOrderItemAction.USER_REQUEST_REFUND_WITH_RECEIVED, REFUNDING)
            );
        }
    },

    REFUNDING("Refunding", true, false) {
        @Override
        public List<Transition<EOmsOrderItemState, EOmsOrderItemAction>> getTransitions() {
            return Arrays.asList(
                    new Transition<>(EOmsOrderItemAction.ADMIN_CONFIRM_REFUND, REFUNDED),
                    new Transition<>(EOmsOrderItemAction.ADMIN_REJECT_REFUND, RECEIVED)

            );
        }
    },

    REFUNDED("Refunding", false, true),

//    REVIEWED("Reviewed", false, false) {
//        @Override
//        public List<Transition<EOmsOrderItemState, EOmsOrderItemAction>> getTransitions() {
//            return Arrays.asList(
//                    new Transition<>(EOmsOrderItemAction.SYSTEM_CREATED)
//            );
//        }
//    },

//    WAIT_SETTLE("Reviewed", false, false) {
//        @Override
//        public List<Transition<EOmsOrderItemState, EOmsOrderItemAction>> getTransitions() {
//            return Arrays.asList(
//                    new Transition<>(EOmsOrderItemAction.SYSTEM_CREATED, COMPLETED)
//            );
//        }
//    },

    REFUND("全部退货", false, true),

    CANCELED("Canceled", false, true),

    COMPLETED("已完成", false, true);;

    private String desc;

    private boolean started;

    private boolean ended;

    EOmsOrderItemState(String desc, boolean started, boolean ended) {
        this.desc = desc;
        this.started = started;
        this.ended = ended;
    }

    @Override
    public String getValue() {
        return desc;
    }

    @Override
    public boolean started() {
        return started;
    }

    @Override
    public boolean ended() {
        return ended;
    }
}
